import {Component, OnInit} from '@angular/core';
import {ProjectStepsComponent} from '../project-steps/project-steps.component';
import {Setting} from "../../../public/setting/setting";
import * as $ from "jquery";
import {BuildProjectService} from "../build-project.service";
import {ActivatedRoute} from "@angular/router";

@Component({
  selector: 'app-project-database',
  templateUrl: './project-database.component.html',
  styleUrls: ['./project-database.component.scss']
})
export class ProjectDatabaseComponent implements OnInit {
  guideLang: any = Setting.PAGEMSG;           //引导语
  dataTables: Array<any> = [];//数据库表
  optionals: Array<any> = [];//操作项
  displayType: Array<any> = [];//操作项
  type: string;
  projectCode: string;

  constructor(public steps: ProjectStepsComponent, private routeInfo: ActivatedRoute,
              private buildProjectService: BuildProjectService) {
    this.steps.current = 2;//添加项目的进度条
  }

  ngOnInit() {
    this.type = this.routeInfo.snapshot.queryParams['type'];
    this.projectCode = this.routeInfo.snapshot.queryParams['projectCode'];
    // this.getListClassTable();//查询该项目的所有表
  }

  /**
   * 查询该项目的所有表
   * @param event
   * @param curPage
   */
  public getListClassTable() {
    let me = this;
    $.when(this.buildProjectService.getListClassTable({projectCode: me.projectCode})).always(data => {
      if (data) {
        this.dataTables = data;
      }
    })
  }

  routerSkip(step){
    this.buildProjectService.routerSkip(step,this.type)
  }

}
